<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script type="text/javascript" src="res/jquery.min.js"></script>
<style type="text/css">
.message{
color:red;
}
.message1{
color:#f5dd0f;
}
.message2{
color:#26a72b;
}

</style>
<link rel="stylesheet" type="text/css" href="res/css/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="res/css/themes/icon.css">
<script type="text/javascript" src="res/jquery.min.js"></script>
<script type="text/javascript" src="res/jquery.easyui.min.js"></script>


</head>
<body>
<form id="ff" action="LoginAction" method="post">
<table>
        <tr>  
           <td>姓名:</td>  
           <td>
              <input id="uname" type="text" name="uname" onblur="checkUserName()" class="easyui-validatebox" 
              data-options="required:true,validType:'minLength[5]'"/>
              </td>          
        </tr>  
        <tr>  
            <td>密码:</td>  
            <td><input id="password" type="password" name="password" class="easyui-validatebox" 
              data-options="required:true"/></td>  
        </tr>
            <tr>
              <td>确认密码:</td>
              <td>
              <input id="rpassword" name="rpassword" type="password" class="easyui-validatebox"     
               required="required" validType="equals['#password']" />  
              </td>
           </tr>
          
        <span id="message" class="message1"></span>
        <tr>
        <td>
        <input id="btn_ok" type="button" onclick="submitForm()" value="提交" >
        </td>
        </tr>
        </table>
        <a href="showtree.jsp">tree</a>
</form>
</body>
<script type="text/javascript">
//function checkUserName(){
	// onblur="checkUserName()" 
//	var uname=$("#uname").val();
//	$.ajax({
//		type:"POST",
//		url:"api/yanzheng",
//		data:"uname="+uname,
	//	success:function(msg){
	//		if(msg.code==1){
	//			$("#message").removeClass();
	//			$("#message").addClass("message");
	//			$("#message").html(msg.message);
	//		}else{
	//			$("#message").removeClass();
	//			$("#message").addClass("message2");
	//			$("#message").html(msg.message);
	//		}
	//	}
//	});
//}

$(function(){
	//用户名验证
	$.extend($.fn.validatebox.defaults.rules, {    
	    minLength: {    
	        validator: function(value, param){  
	        	return value.length> param[0];   
	        },    
	        message: '用户名长度必须在5个字符以上   '
	    }   
	});  
	//密码验证
	$.extend($.fn.validatebox.defaults.rules, {    
	    equals: {    
	        validator: function(value,param){    
	            return value == $(param[0]).val();    
	        },    
	        message: '密码和确认密码不相同.'   
	    }    
	});  
});
//提交验证
function submitForm() {          
            $('form').click(function () {
                var b = $('form').form("enableValidation").form('validate');
                if (b) {                 
                	 $('form').submit(); 
                    alert("成功");
                }
                else { alert("不成功"); }
            });}
 
</script>

</html>